package com.mobilezu.mobile.pushserver.service.impl;

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.mobilezu.mobile.pushserver.dao.PushDataDao;
import com.mobilezu.mobile.pushserver.model.PushData;
import com.mobilezu.mobile.pushserver.service.PushDataService;


public class PushDataServiceImpl implements PushDataService {

	protected final Log log = LogFactory.getLog(getClass());

	private PushDataDao pushDataDao;

	public void setPushDataDao(PushDataDao pushDataDao) {
		this.pushDataDao = pushDataDao;
	}

	@Override
	public void savePushData(PushData pushData) {
		pushDataDao.savePushData(pushData);
	}

	@Override
	public void updatePushData(PushData pushData) {
		pushDataDao.updatePushData(pushData);
	}

	@Override
	public void deletePushData(Long id) {
		pushDataDao.deletePushData(id);
	}

	public PushData queryPushDataById(Long id) {
		return pushDataDao.queryPushDataById(id);
	}

	@Override
	public List<PushData> queryPushDataByDataId(String dataId) {
		return pushDataDao.queryPushDataByDataId(dataId);
	}

	@Override
	public void createPushDatas(List<PushData> pushDatas) {
		for (PushData pushData : pushDatas) {
			savePushData(pushData);
		}
	}

	@Override
	public PushData queryPushDataByUserNameAndDataId(String recvUsername,
			String dataId) {
		List<PushData> list = pushDataDao.queryPushDataByUserNameAndDataId(
				recvUsername, dataId);
		if (list == null || list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}

	@Override
	public List<PushData> queryPushData(PushData pushData) {
		List<PushData> list = pushDataDao.queryPushData(pushData);
		if (list == null || list.isEmpty()) {
			return null;
		}
		return list;
	}

	@Override
	public List<PushData> getPushDatas() {
		return pushDataDao.getPushDatas();
	}

}
